import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

import javax.swing.*;

public class swingFile {
	
	
	private static JFrame window;
	private String fileStr;
	private static JTextArea area;
	private static int n;
	
	
	
	public static void main(String[] args) {
		JFrame window = new JFrame("FileReader");
		window.setSize(500, 700);
		window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		area = new JTextArea(6, 20);
		JScrollPane sp = new JScrollPane(area);
		window.getContentPane().add(sp);
		raceChoice();

	
		window.add(area);
		window.setVisible(true);
	}
	
	
	
	
	private static void raceChoice(){
		
	
		Object[] options = { "ZERG", "TERRAN", "PROTOSS" };
		
		 n = JOptionPane.showOptionDialog(window, "Race: ", "SC2Builds",
				JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE,
				null, options, options[2]);
		
		if(n == 0){
			bZ();

		}else if(n == 1){
			bT();
			
		}else{
			bP();
		}
		

	}
	private static void bZ(){
		JDialog.setDefaultLookAndFeelDecorated(true);
		//zerg builds
	    Object[] selectionValues = { "14/14", "Stephano's 11 min max", "14/16" };
	    String initialSelection = "Select Build";
	    Object selection = JOptionPane.showInputDialog(null, "Which Build?",
	        "Build Order", JOptionPane.QUESTION_MESSAGE, null, selectionValues, initialSelection);
	    
	    System.out.println(selection.toString());
	    if(selection.equals("14/14")){
	    	try
			{
	    		BufferedReader br = new BufferedReader(new FileReader("hi.txt"));
	    		String wholeStr = "";
				String sCurrentLine;
	 
				while ((sCurrentLine = br.readLine()) != null) {
					System.out.println(sCurrentLine);
					wholeStr += sCurrentLine += "\n";
				}
				area.setText(wholeStr);
			} catch (IOException e) {
				e.printStackTrace();
			} 
	 
	    }
	
		
	}
	private static void bT(){
		
		JDialog.setDefaultLookAndFeelDecorated(true);
		//terran builds
	    Object[] selectionValues = { "TERRAN", "Stephano's 11 min max", "6p" };
	    String initialSelection = "Select Build";
	    Object selection = JOptionPane.showInputDialog(null, "Which Build?",
	        "Build Order", JOptionPane.QUESTION_MESSAGE, null, selectionValues, initialSelection);
	    System.out.println(selection.toString());
	    if(selection.equals("TERRAN")){
	    	try
			{
	    		BufferedReader br = new BufferedReader(new FileReader("hi.txt"));
	    		String wholeStr = "";
				String sCurrentLine;
	 
				while ((sCurrentLine = br.readLine()) != null) {
					System.out.println(sCurrentLine);
					wholeStr += sCurrentLine += "\n";
				}
			
				area.setText(wholeStr);
			} catch (IOException e) {
				e.printStackTrace();
			} 
	 
	    }
	
	}
	private static void bP(){
		JDialog.setDefaultLookAndFeelDecorated(true);
		//Protoss builds
	    Object[] selectionValues = { "PROTOSS", "Stephano's 11 min max", "6p" };
	    String initialSelection = "Select Build";
	    Object selection = JOptionPane.showInputDialog(null, "Which Build?",
	        "Build Order", JOptionPane.QUESTION_MESSAGE, null, selectionValues, initialSelection);
	    
	    
	
		
	}


}
